package com.qiang.test01;

import java.io.*;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException, IOException {
        Socket socket=new Socket("192.168.12.46",10000);

        //是本地的流,用来读取本地文件的.
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("E:/岛国/11.png"));

        //写到服务器 --- 网络中的流
        BufferedOutputStream bos=new BufferedOutputStream(socket.getOutputStream());

        int i;
        while((i=bis.read())!=-1){
            bos.write(i);
        }
        //给服务器一个结束标记,告诉服务器文件已经传输完毕
        socket.shutdownOutput();

        BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while((line=br.readLine())!=null){
            System.out.println(line);
        }


        bis.close();
        socket.close();



    }
}

